﻿using KeyStone.Ioc;
using KeyStone.Ioc.Attributes;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace IocContainerExample.TestHarness
{
   public class Example2
   {
      public Example2()
      {
         /*
          * Registration using attributes.
          * Demonstrates a type with an interface and a type without an interface
          
          */


         IIocContainer container = new IocContainer();
         container.RegisterTypesOf<RegisteredDependencyAttribute>();

         IMyExample2 temp = container.Resolve<IMyExample2>();

         Console.WriteLine("Example 2 : {0}" ,temp.Text);

         MyExample2a temp2 = container.Resolve<MyExample2a>();

         Console.WriteLine("Example 2a : {0}", temp2.Text);
      }

   }

   public interface IMyExample2
   {
      string Text { get; set; }
   }

   [RegisteredDependency(Lifetime = Lifetime.PerInstance)]
   public class MyExample2 : IMyExample2
   {
      public MyExample2()
      {
         Text = "hello";
      }

      public string Text { get; set; }
   }

   [RegisteredDependency(Lifetime = Lifetime.PerInstance)]
   public class MyExample2a 
   {
      public MyExample2a()
      {
         Text = "hello a";
      }

      public string Text { get; set; }
   }
}
